package com.leoman.plz_p.presenter;


import com.leoman.plz_p.interfaces.ChangePasswordView;
import com.leoman.plz_p.module.api.UserApi;
import com.leoman.plz_p.module.bean.BaseData;
import com.leoman.plz_p.module.bean.MapData;
import com.leoman.plz_p.subscriber.ResponseSubscriber;

import cn.com.corelib.api.ResponseTransformer;
import cn.com.corelib.base.BasePresenter;

public class ChangePasswordPresenter extends BasePresenter<ChangePasswordView> {

    private UserApi userApi;

    @Override
    protected void onViewAttach() {
        super.onViewAttach();
        userApi=getApi(UserApi.class);
    }

    public void resetPassword(String studentId, String oldPassword,String newPassword){
        getView().showLoading();
        userApi.resetPassword(studentId,oldPassword,newPassword)
                .compose(new ResponseTransformer<>(this.<BaseData<MapData>>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<BaseData<MapData>>(view) {
                    @Override
                    public void success(BaseData<MapData> mapDataBaseData) {
                        view.obtainResetSuccess();
                    }
                });
    }

    @Override
    public void onStart() {

    }
}